package com.sfddata.musicpillow.user;


import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.util.unit.DataSize;

import javax.servlet.MultipartConfigElement;

@EnableFeignClients(basePackages = "com.sfddata.musicpillow.user.feign")
@MapperScan(basePackages = {"com.sfddata.musicpillow.user.dao", "com.sfddata.musicpillow.user.mapper"})
@EnableDiscoveryClient
@SpringBootApplication
@EnableCaching
@EnableAsync // 开启spring异步注解
public class MusicPillowUserApplication {

    public static void main(String[] args) {

        SpringApplication.run(MusicPillowUserApplication.class, args);
    }

    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        //指定文件代销
        factory.setMaxFileSize(DataSize.ofBytes(1048576 * 10));
        /// 设定上传文件大小
        factory.setMaxRequestSize(DataSize.ofBytes(1048576 * 10));
        return factory.createMultipartConfig();
    }
}


